pub fn goldbach_conjecture() -> u64 {
    find_sum_of_odd_composites(6000)
}

fn is_prime(n: u64) -> bool {
    if n <= 1 {
        return false;
    }
    for i in 2..=((n as f64).sqrt() as u64) {
        if n % i == 0 {
            return false;
        }
    }
    true
}

fn check_odd_composite(n: u64) -> bool {
    if n % 2 == 1 && !is_prime(n) {
        for i in 1..=((f64::sqrt((n / 2) as f64)) as u64) {
            let square_twice = 2 * i * i;
            if is_prime(n - square_twice) {
                return true;
            }
        }
    }
    false
}

fn find_sum_of_odd_composites(limit: u64) -> u64 {
    let mut odd_composites = Vec::new();
    let mut num = 9; 
    while odd_composites.len() < 2  && num < limit {
        if !is_prime(num) && !check_odd_composite(num){
            odd_composites.push(num);
        }
        num += 2;
    }
    odd_composites.iter().sum()
}